﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DataChangeTools.SplashModule.Views
{
    /// <summary>
    /// SplashView.xaml 的交互逻辑
    /// </summary>
    public partial class SplashView : Window
    {
        public SplashView()
        {
            InitializeComponent();
            InitAni();
        }

        private void InitAni()
        {
            // 获取LinearGradientBrush资源
            var gradientBrush = (LinearGradientBrush)this.Resources["MyGradientBackground"];

            // 创建颜色动画
            ColorAnimation colorAnimation1 = new ColorAnimation
            {
                To = (Color)ColorConverter.ConvertFromString("#1FA2FF"),
                Duration = TimeSpan.FromSeconds(2),
                AutoReverse = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            ColorAnimation colorAnimation2 = new ColorAnimation
            {
                To = (Color)ColorConverter.ConvertFromString("#CFA6FF"),
                Duration = TimeSpan.FromSeconds(2),
                AutoReverse = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            ColorAnimation colorAnimation3 = new ColorAnimation
            {
                To = (Color)ColorConverter.ConvertFromString("#C2F78C"),
                Duration = TimeSpan.FromSeconds(2),
                AutoReverse = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            // 应用动画到GradientStop
            gradientBrush.GradientStops[0].BeginAnimation(GradientStop.ColorProperty, colorAnimation1);
            gradientBrush.GradientStops[1].BeginAnimation(GradientStop.ColorProperty, colorAnimation2);
            gradientBrush.GradientStops[2].BeginAnimation(GradientStop.ColorProperty, colorAnimation3);
        }
    }
}
